<?php
include_once BONE_ROOT.DS.APP_DIR.DS.'templates'.DS.'technic'.DS.'technic.php';

class template_listing extends template_technic
{

	protected function head()
	{
	?>
	<link type="text/css" rel="stylesheet" href="templates/technic/css/listing.css">
	<script type="text/javascript" language="javascript" src="templates/technic/js/listing.js"></script>
	<?php
	}

	protected function center()
	{
		
		$category_id = $this->get('category_id');
		$technics = $this->get('technics');
		$categories = $this->get('categories');

		$this->toolbar();
		?>

<div class="box">
	<div class="box-tl"><div class="box-tr"><div class="box-tm"></div></div></div>	
	<div class="box-m">

		<h3 class="title"><?php echo $this->get_title(); ?></h3>
		
		<div class="info">
		<form action="./?controller=technic&task=listing" method="post">
		
		选择分类: 
		<select onchange="javascript:selectCategory(this.options[this.selectedIndex].value)">
		<?php 
		echo '<option value="0"> - 所有技术文档 - </option>';
		foreach($categories as $category)
		{
			echo '<option value="'.$category->id.'"';
			if($category->id == $category_id) echo ' selected';
			echo '>- '.$category->name.' -</option>';
		}
		?>
		</select>
		</div>
		
		<table class="list-table">

		<thead>
		<tr>
			<th width="30">#</th><th>标题</th><th width="160">所属分类</th><th width="120">发布时间</th><th width="60">点击量</th><th width="40">编辑</th><th width="40">删除</th>
		</tr>
		</thead>

		<tbody>
		<?php 
		if(count($technics))
		{
			foreach($technics as $technic)
			{
			?>
			<tr onMouseOver="this.className='row-on'" onMouseOut="this.className='row-off'">
			<td align="center"><?php echo $technic->id; ?></td>
			<td><?php echo $technic->title; ?></td>
			<td align="center"><?php echo $categories[$technic->category_id]->name; ?></td>
			<td align="center"><?php echo date('Y-m-d H:i',$technic->create_time); ?></td>
			<td align="center"><?php echo $technic->hits; ?></td>
			<td align="center">
				<a href="./?controller=technic&task=edit&technic_id=<?php echo $technic->id; ?>" class="edit" title="编辑"></a>
			</td>
			<td align="center">
				<a href="./?controller=technic&task=delete&technic_id=<?php echo $technic->id; ?>" class="delete" title="删除"></a>
			</td>
			</tr>
			<?php
			}
		}
		else
		{
		?>
		<tr>
			<td colspan="9">没有记录</td>
		</tr>
		<?php
		}
		?>
		</tbody>
		
		<tfoot>
		<tr>
			<td colspan="9"><?php $this->pagination(); ?></td>
		</tr>
		</tfoot>
		</table>

	</div>
	<div class="box-bl"><div class="box-br"><div class="box-bm"></div></div></div>
</div>
		

		<?php
		
	}	

}
?>